home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / Gui4Cli / Docs / Tutorials / ListViews3.gc < prev    next >
Encoding:
Gui4CLI script  |  1980-01-03  |  3.0 KB  |  103 lines

  1. G4C
  2.  
  3. ; DIRECTORY LISTVIEWS
  4.  
  5. ; A directory lv is like the listers you find in DirOpus and other
  6. ; file managers. They are multi-selectable and have dedicated
  7. ; commands. There is much more that can be done with them than
  8. ; is shown here.. (look at dir.gc)
  9.  
  10.  
  11. WINBIG 156 31 300 177  ListViews3.gc
  12. WinType 11110001
  13.  
  14. xOnLoad
  15. GuiOpen ListViews3.gc
  16.  
  17. xOnClose
  18. GuiQuit ListViews3.gc
  19.  
  20. ; ----------------------- The directory listview
  21.  
  22. ; Note that (like multi-lv's) these lv's "happen" when the user
  23. ; double clicks them. 
  24.  
  25. ; In this case, if the item double-clicked is
  26. ; a directory, then the dir will be entered into automatically
  27. ; and the xLVDirHook event will be executed.
  28.  
  29. ; If it's a file, then the commands attached to the LV (none in
  30. ; this case) would be executed. The name of the file would be
  31. ; in the "lv.file" variable.
  32.  
  33. ; The items in a dir lv need to be line-up, so they look nicer,
  34. ; that's why we declare a fixed width (topaz8) font for this gadget.
  35.  
  36.  
  37. XLISTVIEW 5 2 207 172 "" lv.file "" 10 DIR
  38. gadid 1                              ; the ID of our listview
  39. gadfont topaz.font 8 000             ; you can give any font you want
  40. lvdirhook 1                          ; the number of the LVDirHook event
  41.                                      ; that will be executed whenever a
  42.                                      ; directory is double-clicked
  43.  
  44. ; This is the xLVDirHook event that will be executed on double-clicking
  45. ; a directory - we use it to update the window's title with the name
  46. ; of the directory our listview is at.
  47.  
  48. xLVDirHook 1
  49. setwintitle listviews3.gc '$$lv.dir                       '
  50.  
  51.  
  52. ; ----------------------- The buttons..
  53.  
  54. ; These buttons will control our dir listview..
  55.  
  56.  
  57. XBUTTON 215 2 81 14 "Parent"       ; go to the parent dir
  58. lvuse listviews3.gc 1
  59. lvdir parent
  60. setwintitle listviews3.gc '$$lv.dir                       '
  61.  
  62. XBUTTON 215 16 81 14 "Root"        ; go to the root of the drive
  63. lvuse listviews3.gc 1
  64. lvdir root
  65. setwintitle listviews3.gc '$$lv.dir                       '
  66.  
  67. XBUTTON 215 30 81 14 "Disks"       ; show the device list
  68. lvuse listviews3.gc 1
  69. lvdir disks
  70. setwintitle listviews3.gc 'Device list'
  71.  
  72.  
  73. XBUTTON 215 50 81 14 "All"         ; select all dirs/files
  74. lvuse listviews3.gc 1
  75. lvdir all
  76.  
  77. XBUTTON 215 64 81 14 "None"        ; unselect all selected items
  78. lvuse listviews3.gc 1
  79. lvdir none
  80.  
  81.  
  82. ; This button will list out all the selected items, stating what
  83. ; type they are.. Note that the device list can never be acted upon..
  84. ; It's done for safety, so that gems like "delete DH0:" can be avoided
  85.  
  86. XBUTTON 215 88 81 14 "List"
  87. lvuse listviews3.gc 1              ; use our listview
  88. lvmulti first                      ; goto to first selected item
  89. while $$lv.line > ''               ; while there are selected items..
  90.       say '$$lv.type - $$lv.rec\n' ; show the type & name of each item
  91.       lvmulti off                  ; un-select the item
  92.       lvmulti next                 ; get next item
  93. endwhile                           ; until no more..
  94.  
  95.  
  96.  
  97. ; Easy, wasn't it ? - Now try doing this in C.
  98. ; (see you next year..)
  99.  
  100.  
  101.  
  102.  
  103.